<?php
namespace Qwadmin\Controller;

use Vendor\Page;

class OrderController extends ComController
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 消费/订单 记录
     * */
    public function index()
    {
        $p = $_GET["p"];
        $p = intval($p) > 0 ? $p : 1;

        //订单状态
        //暂时只查询已付费的
        $map["status"] = "1";
        if (!empty($_GET["bdate"])) {
            $map["paytime"] = array("EGT", $_GET["bdate"] . " 00:00:00");
            $this->assign("bdate", $_GET["bdate"]);
        }
        if (!empty($_GET["edate"])) {
            $map["paytime"] = array("ELT", $_GET["edate"] . " 23:59:59");
            $this->assign("edate", $_GET["edate"]);
        }
        if (!empty($_GET["bdate"]) && !empty($_GET["edate"])) {
            $map["paytime"] = array('between', $_GET["bdate"] . " 00:00:00," . $_GET["edate"] . " 23:59:59");
        }


        $class = M('order');
        $pagesize = 20;#每页数量
        $offset = $pagesize * ($p - 1);//计算记录偏移量


        $count = $class->where($map)->count();
        //$list = $class->where($map)->order("order_id desc")->limit($offset . ',' . $pagesize)->select();
        $list = $class->join("qw_user ON qw_order.open_id = qw_user.open_id")->field("qw_user.addtime as u_addtime,money,qw_order.addtime as addtime,paytime,nickname")->order("order_id desc")->limit($offset . ',' . $pagesize)->where($map)->select();
        //echo $class->getLastSql();die;
        //print_r($list);die;

        $page = new \Think\Page($count, $pagesize);
        $page = $page->show();
        $this->assign('list', $list);
        $this->assign('page', $page);
        $this->display();
    }

    private function countfunc($domain)
    {
        $order = M("order");
        //当日统计
        $daynow = date("Y-m-d");
        $where["paytime"] = array("like", $daynow . "%");//完成支付的时间
        $where["addtime"] = array("like", $daynow . "%");//用户进入阅读的时间
        $where["status"] = 1;
        $result["status"] = 0;
        $result["addtime"] = array("like", $daynow . "%");//未完成支付的用户进入阅读的时间

        if (empty($domain)) {
            $data["total"] = number_format($order->where($where)->sum("money") / 100, 2);//当前时间充值金额总数
            $data["already_paid"] = $order->where($where)->count();//当前时间充值的用户数量
            $data["unpaid"] = $order->where($result)->count();//当前时间未充值的用户数量
        } else {
            $rs = D()->query("select (sum(money) / 100) as money from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$daynow%'");
            $data["total"] = number_format($rs[0]["money"], 2);
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$daynow%'");
            $data["already_paid"] = $rs[0]["count"];
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and b.domain = '$domain' and a.addtime like '%$daynow%'");
            $data["unpaid"] = $rs[0]["count"];
        }

        $result["rate"] = $data["already_paid"] / ($data["already_paid"] + $data["unpaid"]);
        $data["rate"] = floor($result["rate"] * 10000) / 10000 * 100;//当前的完成率
        $this->assign("pays_day", $data);
        $this->assign("Today", $daynow);
        //昨日统计
        $todaynow = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
        $where_today["paytime"] = array("like", $todaynow . "%");
        $where_today["addtime"] = array("like", $todaynow . "%");
        $where_today["status"] = 1;
        $consequence["status"] = 0;
        $consequence["addtime"] = array("like", $todaynow . "%");

        if (empty($domain)) {
            $finish["total"] = number_format($order->where($where_today)->sum("money") / 100, 2);//昨天充值金额总数
            $finish["already_paid"] = $order->where($where_today)->count();//昨天充值的用户数量
            $finish["unpaid"] = $order->where($consequence)->count();//昨天未充值的用户数量
        } else {
            $rs = D()->query("select (sum(money) / 100) as money from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$todaynow%'");
            $finish["total"] = number_format($rs[0]["money"], 2);
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$todaynow%'");
            $finish["already_paid"] = $rs[0]["count"];
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and b.domain = '$domain' and a.addtime like '%$todaynow%'");
            $finish["unpaid"] = $rs[0]["count"];
        }

        $consequence["rate"] = $finish["already_paid"] / ($finish["already_paid"] + $finish["unpaid"]);
        $finish["rate"] = floor($consequence["rate"] * 10000) / 10000 * 100;//昨天的完成率
        $this->assign("pays_today", $finish);
        $this->assign("Yesterday", $todaynow);
        //前天统计
        $before_yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
        $where_before_yesterday["paytime"] = array("like", $before_yesterday . "%");
        $where_before_yesterday["addtime"] = array("like", $before_yesterday . "%");
        $where_before_yesterday["status"] = 1;
        $consequence_before_yesterday["status"] = 0;
        $consequence_before_yesterday["addtime"] = array("like", $before_yesterday . "%");

        if (empty($domain)) {
            $finish_before_yesterday["total"] = number_format($order->where($where_before_yesterday)->sum("money") / 100, 2);//前天充值金额总数
            $finish_before_yesterday["already_paid"] = $order->where($where_before_yesterday)->count();//前天充值的用户数量
            $finish_before_yesterday["unpaid"] = $order->where($consequence_before_yesterday)->count();//前天未充值的用户数量
        } else {
            $rs = D()->query("select (sum(money) / 100) as money from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$before_yesterday%'");
            $finish_before_yesterday["total"] = number_format($rs[0]["money"], 2);
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$before_yesterday%'");
            $finish_before_yesterday["already_paid"] = $rs[0]["count"];
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and b.domain = '$domain' and a.addtime like '%$before_yesterday%'");
            $finish_before_yesterday["unpaid"] = $rs[0]["count"];
        }

        $consequence_before_yesterday["rate"] = $finish_before_yesterday["already_paid"] / ($finish_before_yesterday["already_paid"] + $finish_before_yesterday["unpaid"]);
        $finish_before_yesterday["rate"] = floor($consequence_before_yesterday["rate"] * 10000) / 10000 * 100;//前天的完成率
        $this->assign("pays_before_yesterday", $finish_before_yesterday);
        $this->assign("before_yesterday", $before_yesterday);
        //大前天统计
        $days_ago = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 3, date("Y")));
        $where_days_ago["paytime"] = array("like", $days_ago . "%");
        $where_days_ago["addtime"] = array("like", $days_ago . "%");
        $where_days_ago["status"] = 1;
        $consequence_days_ago["status"] = 0;
        $consequence_days_ago["addtime"] = array("like", $days_ago . "%");

        if (empty($domain)) {
            $finish_days_ago["total"] = number_format($order->where($where_days_ago)->sum("money") / 100, 2);//大前天充值金额总数
            $finish_days_ago["already_paid"] = $order->where($where_days_ago)->count();//大前天充值的用户数量
            $finish_days_ago["unpaid"] = $order->where($consequence_days_ago)->count();//大前天未充值的用户数量
        } else {
            $rs = D()->query("select (sum(money) / 100) as money from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$days_ago%'");
            $finish_days_ago["total"] = number_format($rs[0]["money"], 2);
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$days_ago%'");
            $finish_days_ago["already_paid"] = $rs[0]["count"];
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and b.domain = '$domain' and a.addtime like '%$days_ago%'");
            $finish_days_ago["unpaid"] = $rs[0]["count"];
        }

        $consequence_days_ago["rate"] = $finish_days_ago["already_paid"] / ($finish_days_ago["already_paid"] + $finish_days_ago["unpaid"]);
        $finish_days_ago["rate"] = floor($consequence_days_ago["rate"] * 10000) / 10000 * 100;//大前天的完成率
        $this->assign("pays_days_ago", $finish_days_ago);
        $this->assign("days_ago", $days_ago);
        //当月统计
        $monthnow = date("Y-m");
        $where_month["paytime"] = array("like", $monthnow . "%");
        $where_month["addtime"] = array("like", $monthnow . "%");
        $where_month["status"] = 1;
        $outcome["status"] = 0;
        $outcome["addtime"] = array("like", $monthnow . "%");

        if (empty($domain)) {
            $finally["total"] = number_format($order->where($where_month)->sum("money") / 100, 2);//当月时间充值金额总数
            $finally["already_paid"] = $order->where($where_month)->count();//当月时间充值的用户数量
            $finally["unpaid"] = $order->where($outcome)->count();//当月时间未充值的用户数量
        } else {
            $rs = D()->query("select (sum(money) / 100) as money from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$monthnow%'");
            $finally["total"] = number_format($rs[0]["money"], 2);
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain' and a.paytime like '%$monthnow%'");
            $finally["already_paid"] = $rs[0][count];//当月时间充值的用户数量
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and b.domain = '$domain' and a.addtime like '%$monthnow%'");
            $finally["unpaid"] = $rs[0][count];//当月时间未充值的用户数量
        }

        $outcome["rate"] = $finally["already_paid"] / ($finally["already_paid"] + $finally["unpaid"]);
        $finally["rate"] = floor($outcome["rate"] * 10000) / 10000 * 100;//当月的完成率
        $this->assign("pays_month", $finally);
        //累计统计
        $Last["status"] = 1;
        $ultimate["status"] = 0;
        if (empty($domain)) {
            $Last["total"] = number_format($order->where($Last)->sum("money") / 100, 2); //总共充值金额总数
            $Last["already_paid"] = $order->where($Last)->count();//总共充值的用户数量
            $Last["unpaid"] = $order->where($ultimate)->count();//总共未充值的用户数量

        } else {
            $rs = D()->query("select (sum(money) / 100) as money from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain'");
            $Last["total"] = number_format($rs[0]["money"], 2);
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 1 and b.domain = '$domain'");
            $Last["already_paid"] = $rs[0][count];//总共充值的用户数量
            $rs = D()->query("select count(1) as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and b.domain = '$domain'");
            $Last["unpaid"] = $rs[0][count];//总共未充值的用户数量
        }
        $ultimate["rate"] = $Last["already_paid"] / ($Last["already_paid"] + $Last["unpaid"]);
        $Last["rate"] = floor($ultimate["rate"] * 10000) / 10000 * 100;//总共的完成率
        $this->assign("pays_altogether", $Last);
		
		
		//每月充值记录
		if(empty($domain)) {
			//充值
			$month = D()->query("select date(addtime) as time,format(sum(money)/100,2) as money,count(order_id) as count from `qw_order` where date_sub(curdate(), INTERVAL 30 DAY) <= date(`addtime`) and status =1 group by date(addtime) order by addtime desc");
			foreach($month as $key=>$vv){
				$addtime = $vv['time'];
				//当天未充值
				$ncount = D()->query("select count(*)  as count from qw_order where status = 0 and date(addtime) = '$addtime'");
				$month[$key]['ncount'] = $ncount[0]['count'];
				//完成率
				$uldate["rate"]=$vv["count"]/($vv["count"]+$ncount[0]['count']);
				$ulrate["rate"]=floor($uldate["rate"]*10000)/10000*100;//总共的完成率
				$month[$key]['rate'] = $ulrate['rate'];
			}	
			$this->assign('month',$month);
		}else{
			//die;
			$month = D()->query("select date(a.addtime) as time,format(sum(money)/100,2) as money,count(order_id) as count from `qw_order` as a left join qw_user  as b on a.open_id = b.open_id where date_sub(curdate(), INTERVAL 30 DAY) <= date(a.`addtime`) and a.status =1 and b.domain = '$domain' group by date(a.addtime) order by a.addtime desc");	
			foreach($month as $key=>$vv){
				$addtime = $vv['time'];
				//当天未充值
				$ncount = D()->query("select count(*)  as count from qw_order as a left join qw_user as b on a.open_id = b.open_id where a.status = 0 and date(a.addtime) = '$addtime' and b.domain = '$domain'");
				$month[$key]['ncount'] = $ncount[0]['count'];
				//完成率
				$uldate["rate"]=$vv["count"]/($vv["count"]+$ncount[0]['count']);
				$ulrate["rate"]=floor($uldate["rate"]*10000)/10000*100;//总共的完成率
				$month[$key]['rate'] = $ulrate['rate'];
			}
			//dump($month);die;
				$this->assign('month',$month);
		}
		
		
    }

    /**
     * 订单统计
     * */
    public function count()
    {
        $this->countfunc();
        $this->display();
    }

    /**
     * 最全小说统计
     */
    public function zuiquancount()
    {
        //$this->countfunc("qikaism.cn");
        $this->countfunc("kaycat.cn");
        $this->display();
    }

    /**
     * 最多小说统计
     */
    public function zuiduocount()
    {
        $this->countfunc("tdvrkx.cn");
        $this->display();
    }

    /**
     * 最齐小说统计
     */
    public function zuiqicount()
    {
        $this->countfunc("zsykzm.cn");
        $this->display();
    }


    /**
     * 新生活影音统计
     */
    public function xincount()
    {
        $this->countfunc("www.qichezuoyi.com.cn");
        $this->display();
    }

    /**
     *最靓书库
     */
    public function liangcount()
    {
        $this->countfunc("jcyrdjf.cn");
        $this->display();
    }

    /**
     *红颜阅城
     */
    public function hongyancount()
    {
        $this->countfunc("cgcpu.cn");
        $this->display();
    }


    /**
     *最全书库
     */
    public function zuiquanshukucount()
    {
        $this->countfunc("09zzjh.cn");
        $this->display();
    }

    /**
     *最全书城
     */
    public function zuiquanshuchengcount()
    {
        $this->countfunc("elumvy.cn");
        $this->display();
    }

    /**
     *最全书城
     */
    public function wanyueshuchengcount()
    {
        $this->countfunc("bgiki.cn");
        $this->display();
    }
	
	
	/**
	*在线精品小说
	*/
	 public function zaixianjinping()
    {
        $this->countfunc("bfvpi.cn");
        $this->display();
    }

    /**
     * 用户统计
     * */
    public function statistics()
    {
        $user = M(user);
        //今日统计
        $daynow = date("Y-m-d");
        $where_man["addtime"] = array("like", $daynow . "%");
        $where_man["sex"] = 1;
        $where_man["subscribe"] = 1;
        $where_woman["sex"] = 2;
        $where_woman["addtime"] = array("like", $daynow . "%");
        $where_woman["subscribe"] = 1;
        $data_day["man"] = $user->where($where_man)->count();//当日新增男性用户
        $data_day["woman"] = $user->where($where_woman)->count();//当日新增女性用户
        $data_day["total"] = $data_day["man"] + $data_day["woman"];//当日新增用户总量
        $this->assign("added_day", $data_day);
        $this->assign("Today", $daynow);
        //昨日统计
        $todaynow = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
        $where_man_today["addtime"] = array("like", $todaynow . "%");
        $where_man_today["sex"] = 1;
        $where_man_today["subscribe"] = 1;
        $where_woman_today["sex"] = 2;
        $where_woman_today["addtime"] = array("like", $todaynow . "%");
        $where_woman_today["subscribe"] = 1;
        $data_today["man"] = $user->where($where_man_today)->count();//昨日新增男性用户
        $data_today["woman"] = $user->where($where_woman_today)->count();//昨日新增女性用户
        $data_today["total"] = $data_today["man"] + $data_today["woman"];//昨日新增用户总量
        $this->assign("added_today", $data_today);
        $this->assign("Todaynow", $todaynow);
        //前天统计
        $before_yesterdaynow = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
        $where_man_byesterday["addtime"] = array("like", $before_yesterdaynow . "%");
        $where_man_byesterday["sex"] = 1;
        $where_man_byesterday["subscribe"] = 1;
        $where_woman_byesterday["sex"] = 2;
        $where_woman_byesterday["addtime"] = array("like", $before_yesterdaynow . "%");
        $where_man_byesterday["subscribe"] = 1;
        $data_byesterday["man"] = $user->where($where_man_byesterday)->count();//前天新增男性用户
        $data_byesterday["woman"] = $user->where($where_woman_byesterday)->count();//前天新增女性用户
        $data_byesterday["total"] = $data_byesterday["man"] + $data_byesterday["woman"];//前天新增用户总量
        $this->assign("byesterday", $data_byesterday);
        $this->assign("before_yesterdaynow", $before_yesterdaynow);
        //大前天统计
        $days_ago = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 3, date("Y")));
        $where_man_days_ago["addtime"] = array("like", $days_ago . "%");
        $where_man_days_ago["sex"] = 1;
        $where_man_days_ago["subscribe"] = 1;
        $where_woman_days_ago["sex"] = 2;
        $where_woman_days_ago["addtime"] = array("like", $days_ago . "%");
        $where_woman_days_ago["subscribe"] = 1;
        $data_days_ago["man"] = $user->where($where_man_days_ago)->count();//大前天新增男性用户
        $data_days_ago["woman"] = $user->where($where_woman_days_ago)->count();//大前天新增女性用户
        $data_days_ago["total"] = $data_days_ago["man"] + $data_days_ago["woman"];//大前天新增用户总量
        $this->assign("user_days_ago", $data_days_ago);
        $this->assign("days_agonow", $days_ago);
        //大大前天统计
        $days_greatly = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 4, date("Y")));
        $where_man_days_greatly["addtime"] = array("like", $days_greatly . "%");
        $where_man_days_greatly["sex"] = 1;
        $where_man_days_greatly["subscribe"] = 1;
        $where_woman_days_greatly["sex"] = 2;
        $where_woman_days_greatly["addtime"] = array("like", $days_greatly . "%");
        $where_woman_days_greatly["subscribe"] = 1;
        $data_days_greatly["man"] = $user->where($where_man_days_greatly)->count();//大大前天新增男性用户
        $data_days_greatly["woman"] = $user->where($where_woman_days_greatly)->count();//大大前天新增女性用户
        $data_days_greatly["total"] = $data_days_greatly["man"] + $data_days_greatly["woman"];//大大前天新增用户总量
        $this->assign("user_days_greatly", $data_days_greatly);
        $this->assign("days_greatly", $days_greatly);
        //当月统计
        $daymonth = date("Y-m");
        $where_man_month["addtime"] = array("like", $daymonth . "%");
        $where_man_month["sex"] = 1;
        $where_man_month["subscribe"] = 1;
        $where_woman_today["sex"] = 2;
        $where_woman_today["addtime"] = array("like", $daymonth . "%");
        $where_woman_today["subscribe"] = 1;
        $data_month["man"] = $user->where($where_man_month)->count();//当月新增男性用户
        $data_month["woman"] = $user->where($where_woman_today)->count();//当月新增女性用户
        $data_month["total"] = $data_month["man"] + $data_month["woman"];//当月新增用户总量
        $this->assign("added_month", $data_month);
        //累计统计
        $where_man_overall["sex"] = 1;
        $where_man_overall["subscribe"] = 1;
        $where_woman_overall["sex"] = 2;
        $where_woman_overall["subscribe"] = 1;
        $data_overall["man"] = $user->where($where_man_overall)->count();//总共新增男性用户
        $data_overall["woman"] = $user->where($where_woman_overall)->count();//总共新增女性用户
        $data_overall["total"] = $data_overall["man"] + $data_overall["woman"];//总共新增用户总量
        $this->assign("added_overall", $data_overall);

        $this->display();
    }

    public function agent($sid = 0, $p = 1)
    {

        //获得小说的基本分类
        $class_list = D("novel_class")->where("is_other = 0")->select();

        $this->assign("class_list", $class_list);
        //获得小说的其他分类
        $other_class_list = D("novel_class")->where("is_other = 1")->select();

        $this->assign("other_class_list", $other_class_list);

        //查询条件
        if (!empty($_GET["name"])) {
            $map["name"] = array("like", "%" . $_GET["name"] . "%");
            $this->assign("search_name", $_GET["name"]);
        }
        if (!empty($_GET["class_id"])) {
            $map["class_id"] = $_GET["class_id"];
            $this->assign("search_class_id", $_GET["class_id"]);
        }
        if (!empty($_GET["other_class_id"])) {
            $map["other_class_id"] = $_GET["other_class_id"];
            $this->assign("search_other_class_id", $_GET["other_class_id"]);
        }
        if (!empty($_GET["from"])) {
            $map["from"] = $_GET["from"];
            $this->assign("from", $_GET["from"]);
        }
        if ($_GET["is_end"] != -1 && $_GET["is_end"] != "") {
            $map["is_end"] = $_GET["is_end"];
            $this->assign("is_end", $_GET["is_end"]);
        }

        if ($_GET["is_shelf"] != -1 && $_GET["is_shelf"] != "") {
            $map["is_shelf"] = $_GET["is_shelf"];
            $this->assign("is_shelf", $_GET["is_shelf"]);
        }
        $p = $_GET["p"] ? $_GET["p"] : 1;

        $novel = M('Novel');
        $pagesize = 20;#每页数量
        $offset = $pagesize * ($p - 1);//计算记录偏移量
        $count = $novel->where($map)->count();
        //接收值
        $list = $novel->where($map)->order("order_set asc,id desc")->limit($offset . ',' . $pagesize)->select();
        var_dump();
        exit();
        foreach ($list as $x) {
            $dir = "<img src= " . $x['img'] . " /> ";

        }
        $page = new \Think\Page($count, $pagesize);
        $page = $page->show();
        $this->assign('list', $list);
        $this->assign('page', $page);
        $this->display("agent");


    }


     /*//统计最齐小说9/25 - 10/4  每天的充值记录

    public function zuiqiorder()
    {
        $open_id_pre = 'or28-0';
        //2017-09-25 号
        $moneys1 = D('order')->where("status = 1 and paytime like '%2017-09-25%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[0]['money'] = $moneys1 / 100;
        $order_arr[0]['time'] = '2017-09-25';
        //2017-09-26 号
        $moneys2 = D('order')->where("status = 1 and paytime like '%2017-09-26%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[1]['money'] = $moneys2 / 100;
        $order_arr[1]['time'] = '2017-09-26';
        //2017-09-27 号
        $moneys3 = D('order')->where("status = 1 and paytime like '%2017-09-27%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[2]['money'] = $moneys3 / 100;
        $order_arr[2]['time'] = '2017-09-27';
        //2017-09-28 号
        $moneys4 = D('order')->where("status = 1 and paytime like '%2017-09-28%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[3]['money'] = $moneys4 / 100;
        $order_arr[3]['time'] = '2017-09-28';
        //2017-09-29 号
        $moneys5 = D('order')->where("status = 1 and paytime like '%2017-09-29%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[4]['money'] = $moneys5 / 100;
        $order_arr[4]['time'] = '2017-09-29';
        //2017-09-30 号
        $moneys6 = D('order')->where("status = 1 and paytime like '%2017-09-30%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[5]['money'] = $moneys6 / 100;
        $order_arr[5]['time'] = '2017-09-30';
        //2017-10-01 号
        $moneys7 = D('order')->where("status = 1 and paytime like '%2017-10-01%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[6]['money'] = $moneys7 / 100;
        $order_arr[6]['time'] = '2017-10-01';
        //2017-10-02 号
        $moneys8 = D('order')->where("status = 1 and paytime like '%2017-10-02%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[7]['money'] = $moneys8 / 100;
        $order_arr[7]['time'] = '2017-10-02';
        //2017-10-03 号
        $moneys9 = D('order')->where("status = 1 and paytime like '%2017-10-03%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[8]['money'] = $moneys9 / 100;
        $order_arr[8]['time'] = '2017-10-03';
        //2017-10-04 号
        $moneys10 = D('order')->where("status = 1 and paytime like '%2017-10-04%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[9]['money'] = $moneys10 / 100;
        $order_arr[9]['time'] = '2017-10-04';
        $this->assign('data', $order_arr);
        //2017-10-05 号
        $moneys10 = D('order')->where("status = 1 and paytime like '%2017-10-05%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[10]['money'] = $moneys10 / 100;
        $order_arr[10]['time'] = '2017-10-05';
        $this->assign('data', $order_arr);
        $this->display();
    }*/

    /**
     * 统计最齐小说9/25 - 10/4  每天的充值记录
     * 统计最近10天的充值记录情况
     */
    public function zuiqiorder()
    {
        //$today = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
        //统计最齐
        $open_id_pre = 'or28-0';
        //统计所有
        //$open_id_pre = '';
        //2017-09-25 号
        $today10 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 10, date("Y")));
        $moneys1 = D('order')->where("status = 1 and paytime like '%$today10%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[0]['money'] = $moneys1 / 100;
        $order_arr[0]['time'] = '2017-09-25';
        //2017-09-26 号
        $today9 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 9, date("Y")));
        $moneys2 = D('order')->where("status = 1 and paytime like '%$today9%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[1]['money'] = $moneys2 / 100;
        $order_arr[1]['time'] = '2017-09-26';
        //2017-09-27 号
        $today8 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 8, date("Y")));
        $moneys3 = D('order')->where("status = 1 and paytime like '%$today8%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[2]['money'] = $moneys3 / 100;
        $order_arr[2]['time'] = '2017-09-27';
        //2017-09-28 号
        $today7 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 7, date("Y")));
        $moneys4 = D('order')->where("status = 1 and paytime like '%$today7%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[3]['money'] = $moneys4 / 100;
        $order_arr[3]['time'] = '2017-09-28';
        //2017-09-29 号
        $today6 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 6, date("Y")));
        $moneys5 = D('order')->where("status = 1 and paytime like '%$today6%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[4]['money'] = $moneys5 / 100;
        $order_arr[4]['time'] = '2017-09-29';
        //2017-09-30 号
        $today5 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 5, date("Y")));
        $moneys6 = D('order')->where("status = 1 and paytime like '%2017-09-30%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[5]['money'] = $moneys6 / 100;
        $order_arr[5]['time'] = '2017-09-30';
        //2017-10-01 号
        $today4 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 4, date("Y")));
        $moneys7 = D('order')->where("status = 1 and paytime like '%$today4%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[6]['money'] = $moneys7 / 100;
        $order_arr[6]['time'] = '2017-10-01';
        //2017-10-02 号
        $today3 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 3, date("Y")));
        $moneys8 = D('order')->where("status = 1 and paytime like '%$today3%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[7]['money'] = $moneys8 / 100;
        $order_arr[7]['time'] = '2017-10-02';
        //2017-10-03 号
        $today2 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
        $moneys9 = D('order')->where("status = 1 and paytime like '%$today2%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[8]['money'] = $moneys9 / 100;
        $order_arr[8]['time'] = '2017-10-03';
        //2017-10-04 号//昨天
        $today1 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
        $moneys10 = D('order')->where("status = 1 and paytime like '%$today1%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[9]['money'] = $moneys10 / 100;
        $order_arr[9]['time'] = '2017-10-04';
        $this->assign('data', $order_arr);
        //2017-10-05 号//今天
        $today = date("Y-m-d",time());
        $moneys10 = D('order')->where("status = 1 and paytime like '%$today%' and open_id like '%$open_id_pre%'")->sum('money');
        $order_arr[10]['money'] = $moneys10 / 100;
        $order_arr[10]['time'] = '2017-10-05';
        $this->assign('data', $order_arr);
        $this->display('zuiqiorder');
    }
} 